//package com.twd.allcomponent.exception;
//
//import com.twd.allcomponent.common.RespBean;
//import com.twd.allcomponent.i18n.config.CustomMessageSource;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.shiro.authz.AuthorizationException;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.dao.DuplicateKeyException;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.RestControllerAdvice;
//import org.springframework.web.servlet.NoHandlerFoundException;
//
///**
// * 全局异常处理
// */
//@Slf4j
////@RestControllerAdvice
//public class GlobalExceptionHandler {
////    @Autowired
//    CustomMessageSource customMessageSource;
//    private Logger logger = LoggerFactory.getLogger(getClass());
//
//
//    @ExceptionHandler(NoHandlerFoundException.class)
//    public RespBean handlerNoFoundException(Exception e) {
//        logger.error(e.getMessage(), e);
//        return RespBean.error(404, "路径不存在，请检查路径是否正确");
//    }
//
//    @ExceptionHandler(DuplicateKeyException.class)
//    public RespBean handleDuplicateKeyException(DuplicateKeyException e){
//        logger.error(e.getMessage(), e);
//        return RespBean.error("数据库中已存在该记录");
//    }
//
//    @ExceptionHandler(AuthorizationException.class)
//    public RespBean handleAuthorizationException(AuthorizationException e){
//        logger.error(e.getMessage(), e);
//        return RespBean.error("没有权限，请联系管理员授权");
//    }
//
//    @ExceptionHandler(Exception.class)
//    public RespBean handleException(Exception e){
//        logger.error(e.getMessage(), e);
//        return RespBean.error();
//    }
////    @ExceptionHandler(value = CommonException.class)
////public RespBean handler(CommonException e) {
////    log.error("CommonException：----------------{}", e);
////    return RespBean.error(customMessageSource.getMessage(e.getMessage(), null, LocaleContextHolder.getLocale()));
////}
////    @ExceptionHandler(value = Exception.class)
////    public RespBean handler(Exception e) {
////        log.error("运行时异常：----------------{}", e);
////        return RespBean.error(customMessageSource.getMessage(e.getMessage(), null, LocaleContextHolder.getLocale()));
////    }
//}
